package com.hashmap1;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

class Demo{
	int key;
	String message;
	Date time;
	int count;
	int version;
	Demo(int key,String message,Date time,int count,int version){
		this.key=key;
		this.message=message;
		this.time=time;
		this.count=count;
		this.version=version;
	}
	public int getKey() {
		return key;
	}
	public void setKey(int key) {
		this.key = key;
	}
	public String getMessage() {
		return message;
	}
	public void setMessage(String message) {
		this.message = message;
	}
	public Date getTime() {
		return time;
	}
	public void setTime(Date time) {
		this.time = time;
	}
	public int getCount() {
		return count;
	}
	public void setCount(int count) {
		this.count = count;
	}
	public int getVersion() {
		return version;
	}
	public void setVersion(int version) {
		this.version = version;
	}
	public String toString(){
		return key+"\t"+message+"\t"+time+"\t"+count+"\t"+version;
	}
}
public class HashMapTest {
public static void main(String[] args) {
	System.out.println("key"+"\t"+"message"+"\t"+"time"+"\t"+"count"+"\t"+"version");
	Map<Integer, Demo> map=new HashMap<Integer, Demo>();
	Demo d1=new Demo(1, "welcome", new Date(), 1, 1);
	Demo d2=new Demo(2, "welcome", new Date(), 3, 6);
	Demo d3=new Demo(3, "welcome", new Date(), 4, 5);
	Demo d4=new Demo(4, "welcome", new Date(), 5, 4);
	Demo d5=new Demo(5, "welcome", new Date(), 6, 3);
	map.put(d1.getKey(), d1);
	map.put(d2.getKey(), d2);
	map.put(d3.getKey(), d3);
	map.put(d4.getKey(), d4);
	map.put(d5.getKey(), d5);
	
	Set<Integer> key=map.keySet();
	for(int getkey:key){
		System.out.println(map.get(getkey));
	}
	System.out.println("searching key on map");
	System.out.println(map.containsKey(d1.getKey()));
	System.out.println("searching value on map");
	System.out.println(map.containsValue(d1));
}
}
